<?php

    #-------------------------------------------------------------#
	# This file is part of the Tekuna MVC Microframework for PHP. #
	# (c) 2009 Niels Jäckel <niels.jaeckel@tekuna.org>            #
	# Please visit http://tekuna.org/ for more information.       #
	#                                                             #
	# This software is licensed under the MIT License. Please     #
	# view the LICENSE file for the full text of this license.    #
    #-------------------------------------------------------------#


	/**
	 * The main Tekuna singleton class. It holds the
	 * class loader and provides a static class load method.
	 */

	class Tekuna {

		protected $objClassLoader = NULL;


		private function __construct() {

			// set the current Tekuna version
			define('TEKUNA_VERSION', '0.2');

			// check root constant
			if (! defined('TEKUNA_ROOT')) {

				// error message
				throw new Exception('The "TEKUNA_ROOT" constant must be defined!');
			}

			// load required classes
			require_once TEKUNA_ROOT .'org/tekuna/base/TekunaClassLoader.class.php';
			require_once TEKUNA_ROOT .'org/tekuna/base/log/SimpleLogger.class.php';

			// init class loading
			$this -> objClassLoader = new TekunaClassLoader(TEKUNA_ROOT);
		}


		/**
		 * @return the one and only Tekuna instance
		 */

		public static function getInstance() {

			static $objTekuna = NULL;

			if ($objTekuna === NULL) {

				$objTekuna = new Tekuna();
			}

			return $objTekuna;
		}


		/**
		 * Static class load method.
		 *
		 * @param string $sFullQualifiedClass the fully qualified class name e.g. org.tekuna.base.Tekuna for this class
		 */

		public static function load($sFullQualifiedClass) {

			$objTekuna = Tekuna :: getInstance();
			$objTekuna -> objClassLoader -> loadClass($sFullQualifiedClass);
		}


		/**
		 * Because of the singleton nature of this class, it cannot be cloned.
		 */
		private function __clone() {

		}
	}



